package StudyCode.summary.myfile;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributes;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class FileAttributeByReadAttributes {
	public static void main(String[] args) {

		BasicFileAttributes attr = null;
		Path path = Paths.get("E:\\迅雷下载", "test1.txt");

		try {
			attr = Files.readAttributes(path, BasicFileAttributes.class);
		} catch (IOException e) {
			System.err.println(e);
		}

		System.out.println("文件大小: " + attr.size());
		System.out.println("文件创建时间: " + attr.creationTime());
		System.out.println("文件最后访问时间: " + attr.lastAccessTime());
		System.out.println("文件最后修改时间: " + attr.lastModifiedTime());

		System.out.println("是目录? " + attr.isDirectory());
		System.out.println("是常规文件? " + attr.isRegularFile());
		System.out.println("是链接? " + attr.isSymbolicLink());
		System.out.println("是其他? " + attr.isOther());
	}
}
